<!DOCTYPE HTML>
<html lang="fr">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bienvenue sur CSStrat!</title>

    <!-- Custom stylesheet, add only if you MUST, this sheet has priority over the others -->
    <link  rel="stylesheet" href="CSS/style.css">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/csstrat.js"></script>

  </head>
  <?php 
  	if( !isset($_SESSION) ){
      session_start();
    }
  	include(__DIR__.'/../utility.php');
  	$curUser = Utility::loggedIn();
  ?>
  <body>
	<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
					<span class="sr-only">Toggle navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button
>				<a class="navbar-brand" href="./index.php">CSStrat <i class="glyphicon glyphicon-home"></i></a>
			</div>
			<div class="collapse navbar-collapse">
				<ul class="nav navbar-nav">
					<li><a href="./create.php">Cr&eacuteer</a></li>
					<li><a href="./view.php">Consulter</a></li>
				</ul>
				<?php if ( !$curUser ) : ?>
		            <form action="./login.php" method="POST" class="navbar-form navbar-right" role="form">
		              <div class="form-group">
		                <input name="usr" type="text" placeholder="Courriel" class="form-control">
		              </div>
		              <div class="form-group">
		                <input name="pw" type="password" placeholder="Mot de passe" class="form-control">
		              </div>
		              <button type="submit" class="btn btn-success">Authentification</button>
		            </form>
		        <?php else: ?>
		            <ul class="nav navbar-nav navbar-right">
		              <li class="dropdown">
		                <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $curUser ?><b class="caret"></b></a>
		                <ul class="dropdown-menu">
		                  <li><a href="#">Mon profil</a></li>
		                  <li><a href="#">Mes strat&eacute;gies</a></li>
		                  <li class="divider"></li>
		                  <li><a href="logout.php">Se d&eacute;connecter</a></li>
		                </ul>
		              </li>
		            </ul>
		        <?php endif; ?>
			</div><!--/.nav-collapse -->
		</div>
	</div>

	<div class="container" id="main_container">

        <?php
        // ************ MESSAGES SECTION ************ //
        if ( !empty( $_GET['msg'] ) ) {
          		switch ( $_GET['msg'] ) {
          			case 'login':
          				if ( $curUser ) 
          					echo "<div class=\"alert alert-info\">
          							Bonjour <strong>{$curUser}</strong>, vous êtes authentifié avec succès.
          						</div>";
          				break;
          			
          			case 'logout':
          				echo '<div class="alert alert-info">
          						Vous vous êtes déconnecté avec succès.
          					</div>';
          				break;
					case 'nomap':
						echo '<div class="alert alert-info">
          						Veuillez choisir une carte!
          					</div>';
          				break;
					case 'noname':
						echo '<div class="alert alert-info">
          						Veuillez donner un nom a la strategie!
          					</div>';
          				break;
          case 'authfail':
            echo '<div class="alert alert-danger">
                      Mauvaise combinaison compte/mot de passe!
                    </div>';
          case 'mustlogin':
            echo '<div class="alert alert-danger">
                      Vous devez vous authentifier pour accéder à cette page!
                    </div>';
          		}
        }
        // ************ END MESSAGES SECTION ************ //
        ?>